<?php
class Tourism_order_main_model extends CI_Model
{
    private $table = 'tourism_order_main';

    /**
     * 订单支付主表  
     * @param unknown $postData
     */
    public function insertTourismOrderMain($postData)
    {
        $data = array(
            'order_sn'     => $postData['order_sn'],
            'status'       => 1,
            'order_amount' => $postData['order_amount'],
            'created_at'   => date('Y-m-d H:i:s'),
        );
        $this->db->insert($this->table, $data);
        return $this->db->insert_id();
    }
    
    public function findByOrderMain($order_sn){
        $this->db->select('order_sn,status,order_amount');
        $this->db->from($this->table);
        $this->db->where('order_sn',$order_sn);
        $this->db->limit(1);
        return $this->db->get();
    }
    
    public function updateStatus($order_sn,$params)
    {
        $this->db->where('order_sn', $order_sn);
        return $this->db->update($this->table,$params);
    }
    
     /**
     * 更新订单信息
     * @param unknown $order_sn
     * @param unknown $param
     */
    public function updatePayOrderInfo($order_sn,$param)
    {
        $this->db->where('order_sn',$order_sn);
        return $this->db->update($this->table,$param);
    }
}